function GetRequest(url) {
	// var url = location.search; //获取url中"?"符后的字串
	var theRequest = new Object();
	if (url.indexOf("?") != -1) {
		var str = url.substr(1);
		strs = str.split("&");
		for (var i = 0; i < strs.length; i++) {
			theRequest[strs[i].split("=")[0]] = (strs[i].split("=")[1]);
		}
	}
	return theRequest;
}

function confirm(str, url, id1, id2) {
	layui.use([ 'layer' ], function() {
		layer.ready(function() {
			layer.confirm(str, {
				icon : 3,
				title : '提示'
			}, function(index) {
				layer.close(index);
				$.post(sessionStorage.getItem("context_url") + url, data,
						function() {
							window.location.reload();
						});
			});
		});
	})
}

// 错误提示
function errorTips(msg) {
	layui.use([ 'layer' ], function() {
		layer.ready(function() {
			layer.msg(msg, {
				icon : 5,
				anim : 6,
				time : 1500
			});
		});
	});
}

// 正确提示
function OKTips(msg, href) {
	layui.use([ 'layer' ], function() {
		layer.ready(function() {
			layer.msg(msg, {
				icon : 1,
				anim : 1,
				time : 1500
			}, function() {
				//window.location.href = href;
				$('iframe', parent.document).attr('src',href);
			});
		});
	});
}

// currentPage:当前页 pageSize:页面显示数量 totalCount:总数量 fn:方法名
var pageStrip = function(currentPage, pageSize, totalCount, fn) {
	layui.use([ 'laypage' ], function() {
		var laypage = layui.laypage;
		var last = Math.ceil(totalCount / pageSize);
		// 调用分页
		laypage({
			cont : 'pageStrip', // 挂载节点
			pages : last, // 总页码
			groups : 5, // 连续显示分页数
			skin : '#e45050',
			curr : currentPage, // 当前页
			first : 1, // 始终显示首页 false表示不显示
			last : last, // 始终显示末页 false表示不显示
			prev : '<em><</em>', // 自定义上一页
			next : '<em>></em>', // 自定义上一页
			skip : true, // 跳转
			jump : function(obj, first) {
				if (!first)
					fn(obj.curr);
			}
		});
	});
}

var filter_time = function(value) {
	var date = new Date(value);
	Y = date.getFullYear();
	m = date.getMonth() + 1;
	d = date.getDate();
	H = date.getHours();
	i = date.getMinutes();
	s = date.getSeconds();

	if (m < 10) {
		m = '0' + m;
	}
	if (d < 10) {
		d = '0' + d;
	}
	if (H < 10) {
		H = '0' + H;
	}
	if (i < 10) {
		i = '0' + i;
	}
	if (s < 10) {
		s = '0' + s;
	}

	var t = Y + '-' + m + '-' + d + ' ' + H + ':' + i + ':' + s;
	return t;
};

function uploadImg($obj1, $obj2, $obj3,$obj4,args) {
	$obj1.change(function() {
		var file = this.files[0];
		var reader = new FileReader();
		reader.readAsDataURL(file);
		reader.onload = function(e) {
			$obj2.attr("src", this.result);
			$obj3.val(this.result);
			$obj4.remove();
			args.pic = $obj3.val();
		};
	});
	$obj1.click();
}
